﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AppPort;
using TI_EntityLib.TiEntityObjects.AttachInfo;

namespace Controllers.AdministrationControllerCommands
{
    public class SaveAttachContent
    {
        public class inSaveAttachContent
        {
            public string DocID { get; set; }
            public int Part { get; set; }
            public List<TDocumentTable> tables { get; set; }
            public override string ToString()
            {
                //Исключить пустые строчки из tblaes
                List<TDocumentTable> t = new List<TDocumentTable>();
                foreach (TDocumentTable i in tables) {
                    t.Add((TDocumentTable)i.Clone());
                }
                this.tables = t;
                return Helper.Json < inSaveAttachContent>.NewtonSerializeObject(this);
            }
        }      


        public static string Run(ServiceCmd cmd)
        {
            inSaveAttachContent inP = Helper.Json<inSaveAttachContent>.NewtonDeserializeObject(cmd.args.ToString());
            Helper.MongoTools.Instance.ExecuteScript("saveAttachContent("+inP.ToString()+")");

            return "";
        }
    }
}
